package com.my.roco.service.impl;

import com.my.roco.dao.UserMapper;
import com.my.roco.pojo.User;
import com.my.roco.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class UserServiceImpl implements UserService {

    @Autowired
    private UserMapper userMapper;

    @Override
    public void registerUser(User user) {
        userMapper.insertUser(user);
    }

    @Override
    public User login(String account, String password) {
        User user = userMapper.getUserByAccount(account);
        if (user != null && user.getPassword().equals(password)) {
            return user;
        }
        return null;
    }

    @Override
    public User getUserByAccount(String account) {
        return userMapper.getUserByAccount(account);
    }
    @Override
    public void updateUser(User user) {
        userMapper.updateUser(user);
    }
}